// 1863. 找出所有子集的异或总和再求和
// AC: https://leetcode.cn/problems/sum-of-all-subset-xor-totals/submissions/620254322/

class Solution {
public:
    int ans=0;
    int n;
    void dfs(vector<int>& nums,int id,int sum){
        if(id==n){
            ans+=sum;
            return;
        }
        dfs(nums,id+1,sum^nums[id]);
        dfs(nums,id+1,sum);
    }
    int subsetXORSum(vector<int>& nums) {
        n=nums.size();
        dfs(nums,0,0);
        return ans;
    }
};